﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace CPPEI.WebApi2
{
    public interface IActionParams
    {
        void ParseQueryString(HttpRequest request);

        void ParseForm(HttpRequest request);
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class ActionAttribute : Attribute
    {
        public string Scenario { get; set; }
        /// <summary>
        /// action名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 版本号
        /// </summary>
        public string Version { get; set; }
        public string HttpMethod { get; set; }
        public bool IsAnonymous { get; set; }
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class PostActionAttribute : ActionAttribute
    {
        public PostActionAttribute(string scenario, string name, string version)
        {
            HttpMethod = HttpMethods.POST;
            Scenario = scenario;
            Name = name;
            Version = version;
            IsAnonymous = true;
        }

        public PostActionAttribute(string name, string version)
            : this(string.Empty, name, version)
        {
        }
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class AuthPostActionAttribute : ActionAttribute
    {
        public AuthPostActionAttribute(string scenario, string name, string version)
        {
            HttpMethod = HttpMethods.POST;
            Scenario = scenario;
            Name = name;
            Version = version;
            IsAnonymous = false;
        }

        public AuthPostActionAttribute(string name, string version)
            : this(string.Empty, name, version)
        {
        }
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class GetActionAttribute : ActionAttribute
    {
        public GetActionAttribute(string scenario, string name, string version)
        {
            HttpMethod = HttpMethods.GET;
            Scenario = scenario;
            Name = name;
            Version = version;
            IsAnonymous = true;
        }

        public GetActionAttribute(string name, string version)
            : this(string.Empty, name, version)
        {
        }
        public GetActionAttribute(string name)
            : this(string.Empty, name, "1.0")
        {
        }
    }

    [AttributeUsage(AttributeTargets.Class)]
    public class AuthGetActionAttribute : ActionAttribute
    {
        public AuthGetActionAttribute(string scenario, string name, string version)
        {
            HttpMethod = HttpMethods.GET;
            Scenario = scenario;
            Name = name;
            Version = version;
            IsAnonymous = false;
        }

        public AuthGetActionAttribute(string name, string version)
            : this(string.Empty, name, version)
        {
        }

        public AuthGetActionAttribute(string name)
            : this(string.Empty, name, "1.0")
        {
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public class ParameterAttribute : Attribute
    {
        public string Namespace { get; set; }
        public string Name { get; set; }

        public ParameterAttribute(string @namespace, string name)
        {
            Namespace = @namespace;
            Name = name;
        }

        public ParameterAttribute(string name)
            : this(string.Empty, name)
        {
        }

        public ParameterAttribute()
        {

        }
    }
}
